<template>
    <div style="margin-top: 60px;margin-left:330px;width: 300px;height: 500px;border: 0px solid red;" >
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="申请人ID">
                <el-input v-model="$route.query.rid" readonly></el-input>
            </el-form-item>
            <el-form-item label="招聘信息ID">
                <el-input v-model="$route.query.reid" readonly></el-input>
            </el-form-item>
            <el-form-item label="面试地点" prop="interviewPlace">
                <el-input v-model="ruleForm.interviewPlace"></el-input>
            </el-form-item>
            <el-form-item label="面试时间" required>
                <el-col :span="11">
                    <el-form-item prop="interviewTime">
                        <el-date-picker  placeholder="选择日期" v-model="ruleForm.interviewTime"  style="width: 100%;"></el-date-picker>
                    </el-form-item>
                </el-col>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm('ruleForm')">立即同意</el-button>
                <el-button @click="resetForm('ruleForm')">重置</el-button>
            </el-form-item>
        </el-form>
    </div>

</template>

<script>
    export default {
        data() {
            return {
                category:null,
                ruleForm: {
                    interviewTime: '',
                    interviewPlace: '',
                },
                dormitoryList: '',
                rules: {
                    // interviewTime: [
                    //     { required: true, message: '请输入面试时间', trigger: 'blur' }
                    // ],
                    interviewPlace: [
                        { required: true, message: '请输入面试地点', trigger: 'blur' }
                    ]
                }
            };
        },
        methods: {
            submitForm(formName) {
                const _this = this
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        axios.put('http://localhost:8182/application/update'+"/"+_this.$route.query.rid+"/"+_this.$route.query.reid,_this.ruleForm).then(function (resp) {
                            if(resp.data.code == 0){
                                _this.$alert(_this.ruleForm.name+'修改成功', '', {
                                    confirmButtonText: '确定',
                                    callback: action => {
                                        _this.$router.push('/application')
                                    }
                                });
                            }
                        })
                        // console.log(_this.ruleForm)
                        // console.log(_this.$route.query.rid)
                        // console.log(_this.$route.query.reid)
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        },
        // created() {
        //     const _this = this
        //     axios.get('http://localhost:8181/dormitory/availableList').then(function (resp) {
        //         _this.dormitoryList = resp.data.data
        //     })
        //     axios.get('http://localhost:8181/student/findById/'+_this.$route.query.id).then(function (resp) {
        //         _this.ruleForm = resp.data.data
        //     })
        // }
    }
</script>
